<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Bob周的空间 - 周天赐的博客</title><meta name="author" content="周天赐"><meta name="copyright" content="周天赐"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="糟糕，他好像真的在变强！">
<meta property="og:type" content="website">
<meta property="og:title" content="Bob周的空间">
<meta property="og:url" content="https://github.com/Bob20020619/Bob20020619.github.io/index.html">
<meta property="og:site_name" content="Bob周的空间">
<meta property="og:description" content="糟糕，他好像真的在变强！">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://github.com/Bob20020619/Bob20020619.github.io/img/avatar.jpg">
<meta property="article:author" content="周天赐">
<meta property="article:tag" content="Bob周">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://github.com/Bob20020619/Bob20020619.github.io/img/avatar.jpg"><link rel="shortcut icon" href="/Bob20020619/Bob20020619.github.io/img/favicon.png"><link rel="canonical" href="https://github.com/Bob20020619/Bob20020619.github.io/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/Bob20020619/Bob20020619.github.io/css/index.css?v=4.13.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.1/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/Bob20020619/Bob20020619.github.io/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid@4.11.1/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Bob周的空间',
  isPost: false,
  isHome: true,
  isHighlightShrink: true,
  isToc: false,
  postUpdate: '2024-06-16 17:19:21'
}</script><script>(win=>{
      win.saveToLocal = {
        set: (key, value, ttl) => {
          if (ttl === 0) return
          const now = Date.now()
          const expiry = now + ttl * 86400000
          const item = {
            value,
            expiry
          }
          localStorage.setItem(key, JSON.stringify(item))
        },
      
        get: key => {
          const itemStr = localStorage.getItem(key)
      
          if (!itemStr) {
            return undefined
          }
          const item = JSON.parse(itemStr)
          const now = Date.now()
      
          if (now > item.expiry) {
            localStorage.removeItem(key)
            return undefined
          }
          return item.value
        }
      }
    
      win.getScript = (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        script.onerror = reject
        script.onload = script.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          script.onload = script.onreadystatechange = null
          resolve()
        }

        Object.keys(attr).forEach(key => {
          script.setAttribute(key, attr[key])
        })

        document.head.appendChild(script)
      })
    
      win.getCSS = (url, id = false) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onerror = reject
        link.onload = link.onreadystatechange = function() {
          const loadState = this.readyState
          if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
          link.onload = link.onreadystatechange = null
          resolve()
        }
        document.head.appendChild(link)
      })
    
      win.activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
        if (t === 'dark') activateDarkMode()
        else if (t === 'light') activateLightMode()
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
      const detectApple = () => {
        if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
          document.documentElement.classList.add('apple')
        }
      }
      detectApple()
    })(window)</script><meta name="generator" content="Hexo 7.2.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/Bob20020619/Bob20020619.github.io/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/Bob20020619/Bob20020619.github.io/archives/"><div class="headline">文章</div><div class="length-num">8</div></a><a href="/Bob20020619/Bob20020619.github.io/tags/"><div class="headline">标签</div><div class="length-num">3</div></a><a href="/Bob20020619/Bob20020619.github.io/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="page" id="body-wrap"><header class="full_page fixed" id="page-header" style="background-image: url('/Bob20020619/Bob20020619.github.io/img/top.JPG')"><nav id="nav"><span id="blog-info"><a href="/Bob20020619/Bob20020619.github.io/" title="Bob周的空间"><img class="site-icon" src="/Bob20020619/Bob20020619.github.io/img/avatar.jpg"/><span class="site-name">Bob周的空间</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/gallery/"><i class="fa-fw fas fa-images"></i><span> 照片</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/Bob20020619/Bob20020619.github.io/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="site-info"><h1 id="site-title">Bob周的空间</h1><div id="site_social_icons"><a class="social-icon" href="https://github.com/Bob20020619" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:1294811773@qq.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div id="scroll-down"><i class="fas fa-angle-down scroll-down-effects"></i></div></header><main class="layout" id="content-inner"><div class="recent-posts" id="recent-posts"><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E8%B5%B0%E9%A9%AC%E8%A7%82%E8%8A%B1/" title="走马观花">走马观花</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:23:46.853Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E6%95%99%E8%AE%AD/">教训</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></span></div><div class="content">索引什么是索引？索引是帮助MYSQL高效获取数据的有序的数据结构。
无索引的时候，大概率会进行全表扫描，索引帮助我们避免全表扫描。
优点：

提高查询效率；
降低排序成本；

缺点：

占用额外空间；
降低更新效率；

索引的结构B树特点：叶子节点和非叶子节点存储索引和数据；
5阶（最多五个子节点）的B树有最多每个节点有四个小节点；
达到了就向上分裂，具体可以查看网站：www.cs.usfca.edu/~galles/visualization/BTree.html
B+树特点：叶子节点存放数据，非叶子节点存储索引；
Hash特点：哈希表+链表+红黑树，查询效率高，但是不支持范围查询；
为什么InnoDB选择B+树？思路：回答B+树相对于二叉树、B树、Hash的优点；

相对于二叉树：层级低，搜索效率高；
相对于B树：非叶子节点不存数据，叶子节点之间使用指针连接，查询效率稳定，并且范围查询效率高；
相对于Hash：支持范围查询；

索引分类
主键索引：PRIMARY，只有一个

唯一索引：保证数据列不重复，多个；

常规索引：快速定位特定数据；

全文索引：查找文本中的关键字，而不是对 ...</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/" title="项目总结">项目总结</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:23:46.852Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E9%A1%B9%E7%9B%AE/">项目</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></span></div><div class="content">项目总结516红包雨项目总结缓存预热：
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566/** * 定时执行缓存预热任务 * 该方法使用CRON表达式“0 * * * * ?”定时执行，每一分钟执行一次。 * 执行流程包括查询1分钟内的活动，并对每个活动进行缓存预热处理： * 1. 查询活动列表。 * 2. 遍历活动列表，针对每个活动查询奖品列表及数量、缓存活动策略，并生成奖品相关的令牌桶。 * 3. 将活动策略和活动信息缓存到Redis中，包括最大中奖数、最大抽奖数、活动信息和令牌桶。 */@Scheduled(cron = &quot;0 * * * * ?&quot;)public void execute() &#123;    System.out.printf(&quot;scheduled!&quot;+new Date());    /**     * 缓存预热流程**：   ...</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E6%A8%A1%E6%8B%9F%E9%9D%A2%E8%AF%95/" title="模拟面试">模拟面试</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:23:46.851Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E9%9D%A2%E8%AF%95/">面试</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></span></div><div class="content">过期删除
过期字典
被动删除缺点 —&gt; 主动删除缺点
淘汰策略
进行总结：
淘汰范围—&gt;淘汰算法—&gt;
对于淘汰算法，加入自己思考（我认为。。。）—&gt; 
lru ：缺点，热key问题
lfu： 缺点，预热key问题
Zset实现：
过于详细，
两种结构：1、压缩列表：优势、劣势；2、跳表+字典：优势、劣势；
宕机丢失数据：
Redis4.0之后混合策略；
总—分—-总（总结：优缺点）
redis缓存击穿：

缓存预热、永不过期；
使用锁；

将两者联系起来，为什么会有2的方式出现，方式1失效了；
RTreeLock，获取不到锁，返回false：超时中断，秒杀环境，中断。
缓存穿透：
不够流畅；
三种方法—&gt; 缺点—&gt;组合
为什么用布隆过滤器，为什么不用set？串联大key？
布隆过滤器容量不够怎么办？
为什么需要Redis高可用？
单机模式的问题：容易故障、存储上限、性能瓶颈—&gt;如何解决？—-&gt;三种大模式的优缺点
哈希槽为什么是16300个？
为什么分片集群的节点不能越来越多？
Gossip协议，网络延迟，导致脑裂问题
脑裂问题
mysql ...</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%9D%A2%E8%AF%95%E7%BB%8F%E5%8E%86%E8%AE%B0%E5%BD%95/" title="面试经历记录">面试经历记录</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:23:46.849Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E9%9D%A2%E8%AF%95/">面试</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></span></div><div class="content">面试经历记录南京亚信万联南昌分公司问题
自我介绍
项目介绍1. 
MySQL查询关键字
内外连接：inner join 、left join、right join
select、or、limit、group by、order by、distinct（去重）、like、in


Redis数据类型
字符串String：一个key对应一个value
列表List：字符串列表
集合Set：无序集合
散列Hash：key-value，适合存储对象，类似一个对象的多个字段和属性
有序集合Zset


SpringBoot的注解
@SpringBootApplication
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan


Spring依赖注入的注解，区别
@Resource：优先对类名进行注入，当接口有多个实现类时，使用name属性进行标注
@Autowired：优先对类型进行注入，使用@Qualify注解进行名称注入


事务的注解
@transational


@RestController注解，@Requ ...</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E5%A4%A7%E8%AF%9D%E9%9D%A2%E8%AF%95/" title="大话面试">大话面试</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:23:46.843Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E9%9D%A2%E8%AF%95/">面试</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></span></div><div class="content">缓存如何解决缓存击穿？什么是缓存击穿？
当某个缓存数据不存在或者过期了，有大量请求访问该数据，由于缓存不存在，则会进入数据库，给数据库造成巨大压力，称为缓存击穿。
如何解决缓存击穿？

缓存预热：例如，活动开始的时候，给有可能会被大量访问的数据进行缓存；
设置热点数据永不过期：对一些热点数据设置永不过期；
使用分布式锁：使用Redisson分布式锁，当判断缓存不存在的时候，获取互斥锁，然后再一次查询缓存是否存在，如果不存在，则查询数据库，然后将数据添加到缓存中，释放互斥锁。

如何解决缓存穿透？什么是缓存穿透？
当某个数据不存在的时候，大量请求访问该数据，由于缓存不存在，则会进入数据库，给数据库造成巨大压力。
如何解决缓存穿透？

缓存空值：
给不存在的数据，缓存空值；查询key是否存在空值，存在则返回，否则查询数据库，存在则返回数据，否则返回空值，并缓存key为空值；
缺点：当有大量恶意请求的时候，会对缓存造成压力；


使用锁：
当数据不存在进行数据库查询的时候，使用锁来限制只有获取锁的线程可以访问数据库；
缺点：当查询的数据实际存在，但是不存在缓存中时，请求依然会被锁限制，大大降 ...</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E4%BB%8EGitLab%E4%B8%8A%E6%8B%89%E5%8F%96%E9%A1%B9%E7%9B%AE/" title="从GitLab上拉取项目">从GitLab上拉取项目</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:21:13.091Z" title="发表于 2024-06-16 14:21:13">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E6%95%99%E8%AE%AD/">教训</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/">干货</a></span></div><div class="content">
创建一个问渐渐，放你本地项目。
右键打开git bash here
更换你所使用的用户名和邮箱：
git config –global user.name “name”
git config –global user.eamil “email”


生成密匙
ssh-keygen -t rsa -C “您的邮箱地址”


将生成的公钥配置到gitlab上
git clone 项目地址url，注意这里不是ssh链接，没有用！！！

</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E4%BB%A3%E7%A0%81%E9%9A%8F%E6%83%B3%E5%BD%95/" title="代码随想录">代码随想录</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T06:00:32.203Z" title="发表于 2024-06-16 14:00:32">2024-06-16</time></span><span class="article-meta"><span class="article-meta-separator">|</span><i class="fas fa-inbox"></i><a class="article-meta__categories" href="/Bob20020619/Bob20020619.github.io/categories/%E7%AE%97%E6%B3%95/">算法</a></span><span class="article-meta tags"><span class="article-meta-separator">|</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/code/">code</a><span class="article-meta-link">•</span><i class="fas fa-tag"></i><a class="article-meta__tags" href="/Bob20020619/Bob20020619.github.io/tags/Markdown/">Markdown</a></span></div><div class="content">数组704.二分查找题目描述给定一个升序排列的数组nums，元素不重复，给定一个整数target，当数组中含有target时，返回下标，否则返回-1。
解题思路对于顺序排列，且不重复的数组，进行查找元素时，可以使用二分查找。
1234567891011121314int l = 0,h = nums.length;int m = (l+h)/2;while(l &lt;= h &amp;&amp; m &lt; nums.length)&#123;    if(nums[m] &lt; target)&#123;        l = m + 1;    &#125;    if(nums[m] &gt; target)&#123;        h = m - 1;    &#125;    if(nums[m] == target)        return m;    m = (l+h)/2;&#125;return -1;



27.移除元素题目描述给定一个数组和一个值val，你需要原地移除所有数值等于val的元素，并返回移除后数组的新长度，必须仅使用O（1）的空间
解题思 ...</div></div></div><div class="recent-post-item"><div class="recent-post-info no-cover"><a class="article-title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/hello-world/" title="Hello World">Hello World</a><div class="article-meta-wrap"><span class="post-meta-date"><i class="far fa-calendar-alt"></i><span class="article-meta-label">发表于</span><time datetime="2024-06-16T05:35:07.801Z" title="发表于 2024-06-16 13:35:07">2024-06-16</time></span></div><div class="content">Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new &quot;My New Post&quot;

More info: Writing
Run server1$ hexo server

More info: Server
Generate static files1$ hexo generate

More info: Generating
Deploy to remote sites1$ hexo deploy

More info: Deployment
</div></div></div><nav id="pagination"><div class="pagination"><span class="page-number current">1</span></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/Bob20020619/Bob20020619.github.io/img/avatar.jpg" onerror="this.onerror=null;this.src='/Bob20020619/Bob20020619.github.io/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">周天赐</div><div class="author-info__description">糟糕，他好像真的在变强！</div></div><div class="card-info-data site-data is-center"><a href="/Bob20020619/Bob20020619.github.io/archives/"><div class="headline">文章</div><div class="length-num">8</div></a><a href="/Bob20020619/Bob20020619.github.io/tags/"><div class="headline">标签</div><div class="length-num">3</div></a><a href="/Bob20020619/Bob20020619.github.io/categories/"><div class="headline">分类</div><div class="length-num">4</div></a></div><a id="card-info-btn" href="https://github.com/Bob20020619"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/Bob20020619" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:1294811773@qq.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">糟糕，他好像真的在变强！</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E8%B5%B0%E9%A9%AC%E8%A7%82%E8%8A%B1/" title="走马观花">走马观花</a><time datetime="2024-06-16T06:23:46.853Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%A1%B9%E7%9B%AE%E6%80%BB%E7%BB%93/" title="项目总结">项目总结</a><time datetime="2024-06-16T06:23:46.852Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E6%A8%A1%E6%8B%9F%E9%9D%A2%E8%AF%95/" title="模拟面试">模拟面试</a><time datetime="2024-06-16T06:23:46.851Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E9%9D%A2%E8%AF%95%E7%BB%8F%E5%8E%86%E8%AE%B0%E5%BD%95/" title="面试经历记录">面试经历记录</a><time datetime="2024-06-16T06:23:46.849Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/Bob20020619/Bob20020619.github.io/2024/06/16/%E5%A4%A7%E8%AF%9D%E9%9D%A2%E8%AF%95/" title="大话面试">大话面试</a><time datetime="2024-06-16T06:23:46.843Z" title="发表于 2024-06-16 14:23:46">2024-06-16</time></div></div></div></div><div class="card-widget card-categories"><div class="item-headline">
            <i class="fas fa-folder-open"></i>
            <span>分类</span>
            
            </div>
            <ul class="card-category-list" id="aside-cat-list">
            <li class="card-category-list-item "><a class="card-category-list-link" href="/Bob20020619/Bob20020619.github.io/categories/%E6%95%99%E8%AE%AD/"><span class="card-category-list-name">教训</span><span class="card-category-list-count">2</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/Bob20020619/Bob20020619.github.io/categories/%E7%AE%97%E6%B3%95/"><span class="card-category-list-name">算法</span><span class="card-category-list-count">1</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/Bob20020619/Bob20020619.github.io/categories/%E9%9D%A2%E8%AF%95/"><span class="card-category-list-name">面试</span><span class="card-category-list-count">3</span></a></li><li class="card-category-list-item "><a class="card-category-list-link" href="/Bob20020619/Bob20020619.github.io/categories/%E9%A1%B9%E7%9B%AE/"><span class="card-category-list-name">项目</span><span class="card-category-list-count">1</span></a></li>
            </ul></div><div class="card-widget card-tags"><div class="item-headline"><i class="fas fa-tags"></i><span>标签</span></div><div class="card-tag-cloud"><a href="/Bob20020619/Bob20020619.github.io/tags/code/" style="font-size: 1.15em; color: rgb(98, 63, 41)">code</a><a href="/Bob20020619/Bob20020619.github.io/tags/Markdown/" style="font-size: 1.45em; color: rgb(192, 3, 109)">Markdown</a><a href="/Bob20020619/Bob20020619.github.io/tags/%E5%B9%B2%E8%B4%A7/" style="font-size: 1.3em; color: rgb(109, 41, 114)">干货</a></div></div><div class="card-widget card-archives"><div class="item-headline"><i class="fas fa-archive"></i><span>归档</span></div><ul class="card-archive-list"><li class="card-archive-list-item"><a class="card-archive-list-link" href="/Bob20020619/Bob20020619.github.io/archives/2024/06/"><span class="card-archive-list-date">六月 2024</span><span class="card-archive-list-count">8</span></a></li></ul></div><div class="card-widget card-webinfo"><div class="item-headline"><i class="fas fa-chart-line"></i><span>网站资讯</span></div><div class="webinfo"><div class="webinfo-item"><div class="item-name">文章数目 :</div><div class="item-count">8</div></div><div class="webinfo-item"><div class="item-name">已运行时间 :</div><div class="item-count" id="runtimeshow" data-publishDate="2023-12-31T16:00:00.000Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站访客数 :</div><div class="item-count" id="busuanzi_value_site_uv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">本站总访问量 :</div><div class="item-count" id="busuanzi_value_site_pv"><i class="fa-solid fa-spinner fa-spin"></i></div></div><div class="webinfo-item"><div class="item-name">最后更新时间 :</div><div class="item-count" id="last-push-date" data-lastPushDate="2024-06-16T09:19:21.257Z"><i class="fa-solid fa-spinner fa-spin"></i></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2024 By 周天赐</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Bob周的博客</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/Bob20020619/Bob20020619.github.io/js/utils.js?v=4.13.0"></script><script src="/Bob20020619/Bob20020619.github.io/js/main.js?v=4.13.0"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0.33/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>